package org.sja.log2traffic;

import org.sja.log2traffic.dataStructures.ConfigurationEntity;
import org.sja.log2traffic.dataStructures.ILogData;
import org.sja.log2traffic.dataStructures.ProcessingStatusEntity;

public class LogAnalyzer {
	
	public LogAnalyzer() {
	}

	public void process(ConfigurationEntity configuration, ILogData[] logData, ProcessingStatusEntity processingStatusEntity) {
		ILogDataModyficator respSaveResultParser;
		try {
			respSaveResultParser = configuration.getLogLineParserClass().newInstance();
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
		ILogLineProvider logLineProvider = LogAnalyzerFactory.getInstance().provideLogLineProvider();
		logLineProvider.init(configuration, processingStatusEntity);
		String line = logLineProvider.readLine(processingStatusEntity);
		while (line != null) {
			respSaveResultParser.modifyRawData(logData, line);
			line = logLineProvider.readLine(processingStatusEntity);
		}
	}


}
